/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.apache.wikimark;

/**
 * The callback interface for test events the methods are called in sequence in following order
 * <pre>
 * {@link #onStart} 
 * {
 *     {@link #onTestSetup} 
 *     { 
 *     	{@link #onTestStart}
 *     	{@link #onTestFinish} 
 *     }+ 
 *     {@link #onTestTeardown}
 * }+ 
 * {@link #onFinish}
 * </pre>
 * 
 * @author Sergey I. Salishev
 */
public interface TestEventListener {
	
	/**
	 * The test result structure
	 * @author Sergey I. Salishev
	 */
	public static class TestResult {
		/**
		 * time spent in test in milliseconds
		 */
		public final long timeElapsed;
		/**
		 * length of the test output in bytes
		 */
		public final long outputLength;
		
		/**
		 * @param timeElapsed time spent in test in milliseconds
		 * @param outputLength length of the test output in bytes
		 */
		public TestResult(long timeElapsed, long outputLength) {
			this.timeElapsed = timeElapsed;
			this.outputLength = outputLength;
		}
	}
	/**
	 * called on test suite start 
	 */
	void onStart();
	/**
	 * Called before subtest starts prepare the test data 
	 * @param threads number for threads used for testing
	 */
	void onTestSetup(int threads);
	
	/**
	 * Called before starting the actual measurements
	 * @param request the number of successive request for page
	 */
	void onTestStart(int request);
	
	/**
	 * called on finising the subtest measurements
	 * @param res test result
	 */
	void onTestFinish(TestResult res);
	
	/**
	 * Called before the subtest data is destroyed 
	 */
	void onTestTeardown();
	
	/**
	 * called on test suite end
	 */
	void onFinish();
}
